package com.nnee.p_pr.p_heartbeat;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.os.SystemClock;
import android.util.SparseArray;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class cls_AndroidHeartBeatService extends BroadcastReceiver
  implements cls_c
{
  private static final String b = "AndroidHeartBeatService";
  private static final String c = "IM_HEARTBEAT";
  private static final String d = "com.android.im.intent.action.HEARTBEAT";
  private static final Uri e = Uri.parse("content://im/heartbeat");
  private static final String f = "vnd.android.im/heartbeat";
  private static boolean g = false;
  private static cls_AndroidHeartBeatService h;
  private static final ExecutorService i = Executors.newSingleThreadExecutor();
  private static int m = 0;
  PowerManager.WakeLock a;
  private final Context j;
  private final AlarmManager k;
  private final SparseArray l;

  private cls_AndroidHeartBeatService(Context paramContext)
  {
    this.j = paramContext;
    this.k = ((AlarmManager)paramContext.getSystemService("alarm"));
    this.a = ((PowerManager)paramContext.getSystemService("power")).newWakeLock(1, "IM_HEARTBEAT");
    this.l = new SparseArray();
  }

  public static cls_AndroidHeartBeatService a(Context paramContext)
  {
    if (h == null)
      h = new cls_AndroidHeartBeatService(paramContext);
    return h;
  }

  /** @deprecated */
  private static int b()
  {
    monitorenter;
    try
    {
      int n = m;
      m = n + 1;
      monitorexit;
      return n;
    }
    finally
    {
      localObject = finally;
      monitorexit;
    }
    throw localObject;
  }

  private d c(a parama)
  {
    int n = 0;
    d locald;
    if (n < this.l.size())
    {
      locald = (d)this.l.valueAt(n);
      if (locald.b != parama);
    }
    while (true)
    {
      return locald;
      n++;
      break;
      locald = null;
    }
  }

  /** @deprecated */
  public void a()
  {
    monitorenter;
    int n = 0;
    try
    {
      while (n < this.l.size())
      {
        a((d)this.l.valueAt(n));
        n++;
      }
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
    }
    throw localObject;
  }

  /** @deprecated */
  public void a(cls_a parama, long paramLong)
  {
    monitorenter;
    try
    {
      d locald = c(parama);
      if (locald == null)
      {
        locald = new d();
        int n = b();
        locald.b = parama;
        Uri localUri = ContentUris.withAppendedId(e, n);
        Intent localIntent = new Intent("com.android.im.intent.action.HEARTBEAT").setDataAndType(localUri, "vnd.android.im/heartbeat");
        locald.a = PendingIntent.getBroadcast(this.j, 0, localIntent, 0);
        if ((this.l.size() == 0) && (!g))
        {
          com.nnee.p_g.cls_b.e("AndroidHeartBeatService", "registerReceiver Heartbeat");
          if (this.j.registerReceiver(this, IntentFilter.create("com.android.im.intent.action.HEARTBEAT", "vnd.android.im/heartbeat")) == null)
            com.nnee.p_g.cls_b.f("AndroidHeartBeatService", "startHeartbeat registerReceiver Heartbeat intent==null");
          g = true;
        }
        this.l.append(n, locald);
      }
      a(locald, paramLong);
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
    }
    throw localObject;
  }

  /** @deprecated */
  void a(d paramd)
  {
    monitorenter;
    try
    {
      this.k.cancel(paramd.a);
      int n = this.l.indexOfValue(paramd);
      if (n >= 0)
        this.l.delete(this.l.keyAt(n));
      if ((this.l.size() == 0) && (g))
      {
        com.nnee.p_g.cls_b.e("AndroidHeartBeatService", "unregisterReceiver Heartbeat");
        this.j.unregisterReceiver(this);
        g = false;
      }
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
    }
    throw localObject;
  }

  /** @deprecated */
  void a(d paramd, long paramLong)
  {
    monitorenter;
    try
    {
      long l1 = paramLong + SystemClock.elapsedRealtime();
      this.k.set(2, l1, paramd.a);
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
    }
    throw localObject;
  }

  public boolean a(a parama)
  {
    if (c(parama) != null);
    for (int n = 1; ; n = 0)
      return n;
  }

  /** @deprecated */
  public void b(a parama)
  {
    monitorenter;
    try
    {
      d locald = c(parama);
      if (locald != null)
        a(locald);
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
    }
    throw localObject;
  }

  /** @deprecated */
  public void b(a parama, long paramLong)
  {
    monitorenter;
    try
    {
      d locald = c(parama);
      if (locald != null)
        this.k.cancel(locald.a);
      while (true)
      {
        a(locald, paramLong);
        return;
        locald = new d();
        int n = b();
        locald.b = parama;
        Uri localUri = ContentUris.withAppendedId(e, n);
        Intent localIntent = new Intent("com.android.im.intent.action.HEARTBEAT").setDataAndType(localUri, "vnd.android.im/heartbeat");
        locald.a = PendingIntent.getBroadcast(this.j, 0, localIntent, 0);
        if ((this.l.size() == 0) && (!g))
        {
          if (this.j.registerReceiver(this, IntentFilter.create("com.android.im.intent.action.HEARTBEAT", "vnd.android.im/heartbeat")) == null)
            com.nnee.p_g.cls_b.f("AndroidHeartBeatService", "reStartHeartbeat registerReceiver Heartbeat intent==null");
          g = true;
        }
        this.l.append(n, locald);
      }
    }
    finally
    {
      monitorexit;
    }
    throw localObject;
  }

  public void onReceive(Context paramContext, Intent paramIntent)
  {
    int n = (int)ContentUris.parseId(paramIntent.getData());
    d locald = (d)this.l.get(n);
    if (locald == null);
    while (true)
    {
      return;
      i.execute(new cls_b(this, locald));
    }
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.pris.heartbeat.AndroidHeartBeatService
 * JD-Core Version:    0.6.0
 */